//
//  JoinUsRecruitDetailFooterCell.swift
//  甜言蜜语
//
//  Created by yingli_yanfa_liuxingyu on 16/8/1.
//  Copyright © 2016年 wl. All rights reserved.
//

import UIKit

class JoinUsRecruitDetailFooterCell: UITableViewCell {
    @IBOutlet weak var tableView: UITableView!
    
    var modelList: [JoinUsModel]?
    
    override func awakeFromNib() {
        super.awakeFromNib()
         self.tableView.scrollEnabled = false
        
        let cellNib = UINib(nibName: "JoinUsRecruitFooterCell2", bundle: nil)
        
        self.tableView.registerNib(cellNib, forCellReuseIdentifier: "JoinUsRecruitFooterCell2")
        // Initialization code
    }

    override func setSelected(selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }
    
    func setCellContentWithCellInfo(cellInfo: [JoinUsModel]?) -> Void {
        
        self.modelList = cellInfo
        
        self.tableView.reloadData()
        
        
    }
    
    func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        if modelList?.count == nil{
            return 0
        }else{
            return (modelList?.count)!
        }
        
    }
    func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
        
        return 90
        
        
    }
    func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
        
        let cell = tableView.dequeueReusableCellWithIdentifier("JoinUsRecruitFooterCell2", forIndexPath: indexPath) as! JoinUsRecruitFooterCell2
        
        let model = modelList![indexPath.row]
        cell.titleLbl.text = model.title
        cell.unittag.text = model.unittag
        cell.unittag.backgroundColor = UIColor.yellowColor()
        cell.unitareaLbl.text = model.unitarea
        cell.unitaddress.text = model.unitaddress
        cell.payLbl.text = model.pay
        
        return cell
    }
    
    // MARK: - Table view delegate
    func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
        
        tableView.deselectRowAtIndexPath(indexPath, animated: true)
        
        let model = modelList![indexPath.row]
        
        let dic = ["id":model.id, "type":model.type]
    NSNotificationCenter.defaultCenter().postNotificationName("JoinUsRecruitDetail_Noti", object: dic)
    }

    
}
